package com.ldr.custom.spring.v3.aop.intercept;

import org.aopalliance.intercept.MethodInvocation;

import java.lang.reflect.Method;

public class GPAfterThrowingAdviceInterceptor extends GPAbstractAspectAdvice implements GPMethodInterceptor {

    private String throwName;

    public GPAfterThrowingAdviceInterceptor(Method aspectMethod, Object aspectTarget) {
        super(aspectMethod, aspectTarget);
    }

    @Override
    public Object invoke(GPReflectiveMethodInvocation mi) throws Throwable {
        try {
            return mi.proceed();
        } catch (Throwable e) {
            invokeAdviceMethod(mi,null,e.getCause());
            return  e;
        }
    }

    public void setThrowName(String throwName){
        this.throwName=throwName;
    }
}
